import axios, {AxiosRequestConfig, AxiosResponse} from "axios";

const baseURL = "http://localhost:8897";

const request = axios.create()

//请求拦截器
request.interceptors.request.use((config: AxiosRequestConfig) => {
    if (config.headers) {
        config.headers.token = localStorage.getItem('token') || ''
    }
    return config
}, (error: any) => {
    return Promise.reject(error)
})
//响应拦截器
request.interceptors.response.use((response: AxiosResponse) => {
    return response.data
}, (error: any) => {
    //这里直接做处理
    return Promise.reject(error)
})
export default request

